﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace WinFormTest
{
    public static class JsonNewtonsoft
    {
        /// <summary>
        /// 把对象转换为JSON字符串
        /// </summary>
        /// <param name="o">对象</param>
        /// <returns>JSON字符串</returns>
        public static string ToJSON(this object o)
        {
            if (o == null)
            {
                return null;
            }
            var timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
            //return JsonConvert.SerializeObject(o, timeConverter);
            return JsonConvert.SerializeObject(o);
        }

        /// <summary>
        /// 把Json文本转为实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="input"></param>
        /// <returns></returns>
        public static T FromJSON<T>(this string input)
        {
            try
            {
                return JsonConvert.DeserializeObject<T>(input);
            }
            catch (Exception ex)
            {
                return default(T);
            }
        }
    }

    #region 魔蝎社保报告数据

    public class MxSecurityReportData
    {
        public string code { get; set; }
        public string message { get; set; }
        public string update_time { get; set; }
        public Basic_Info basic_info { get; set; }
        public Social_Insurance_Summary social_insurance_summary { get; set; }
        public Medical_Insurance_Bill medical_insurance_bill { get; set; }
        public Medical_Consumption_Details medical_consumption_details { get; set; }
    }

    public class Basic_Info
    {
        public User_Basic_InfoS user_basic_info { get; set; }
        public User_Basic_Info_Check user_basic_info_check { get; set; }
    }

    public class User_Basic_InfoS
    {
        public string real_name { get; set; }
        public string sex { get; set; }
        public string birth_day { get; set; }
        public string nation { get; set; }
        public string household_registration { get; set; }
        public string address { get; set; }
        public string phone { get; set; }
        public string social_security_no { get; set; }
        public string personnel_status { get; set; }
        public string insured_unit { get; set; }
        public string amount_sum { get; set; }
        public string money_sum { get; set; }
        public string pay_status { get; set; }
        public string first_insured_date { get; set; }
        public string base_number { get; set; }
    }

    public class User_Basic_Info_Check
    {
        public string card_decide { get; set; }
    }

    public class Social_Insurance_Summary
    {
        public Society_Detail[] society_detail { get; set; }
    }

    public class Society_Detail
    {
        public string first_insured_date { get; set; }
        public string insurance_type { get; set; }
        public string insurance_name { get; set; }
        public string corporation_name { get; set; }
        public string amount_sum_2 { get; set; }
        public string month_cnt { get; set; }
        public string month_cont { get; set; }
        public string month_stop { get; set; }
        public string month_stop_all { get; set; }
        public string stop_cnt { get; set; }
        public string stop_cnt_all { get; set; }
        public string patch_cnt { get; set; }
        public string corporation_name_cnt_6 { get; set; }
        public string corporation_name_cnt_12 { get; set; }
        public string corporation_name_cnt_24 { get; set; }
    }

    public class Medical_Insurance_Bill
    {
        public Medical_Insurance_Pay medical_insurance_pay { get; set; }
    }

    public class Medical_Insurance_Pay
    {
        public dynamic medical_insurance_type { get; set; }
        public dynamic base_number { get; set; }
        public dynamic corporation_payment { get; set; }
        public dynamic personal_payment { get; set; }
        public dynamic status { get; set; }
    }

    public class Medical_Consumption_Details
    {
        public Medical_Consumption_Basic medical_consumption_basic { get; set; }
        public Medical_Consumption_Record medical_consumption_record { get; set; }
    }

    public class Medical_Consumption_Basic
    {
        public dynamic month_money_sum { get; set; }
        public dynamic medical_insurance_cnt { get; set; }
        public dynamic month_money_max { get; set; }
    }

    public class Medical_Consumption_Record
    {
        public Securities_Report[] securities_report { get; set; }
    }

    public class Securities_Report
    {
        public string organization_name { get; set; }
        public string type { get; set; }
        public string settlemen_time { get; set; }
        public string money { get; set; }
    }

    #endregion

}
